#pragma once
#include "CallBack.h"
#include "TSingle.h"

namespace mini
{
	extern void threadTimerEngine(void* lp);
	class CTimerEngine : public TSingle<CTimerEngine>
	{
		friend class CEngine;
		friend void threadTimerEngine(void* lp);
	public:
		CTimerEngine();
		virtual ~CTimerEngine();
		void registerCall(CCallBack* pCallBack, int runCount = 0, int DealyRunTime = 0 );

	private:
		bool onStart();
		void onRun();
		void onShutDown();

	private:
		std::atomic_bool 	mbOver = false;
		std::vector<std::list<CCallBack*> > mCallBackList;
		bool 	mbThredOver = false;
		DWORD mCurrentTime = 0;
		BYTE mCurrentIndex = 0;
	};
}